package common


func GetCache(key string,cacheMiss func(func(data string)), cb func(e error, res string)) {
	redis := GetRedis()
	var err error
	tokenRedis, err := redis.GetRedisClient("token")
	if err != nil {
		cb(err, "")
	}
	cache := tokenRedis.Get(key).Val()
	if cache == "" {
		cacheMiss(func(data string) {
			tokenRedis.Set(key, data, 23 * 3600)
			cb(nil, data)
		})
	} else {
		cb(nil, cache)
	}
}
